﻿using DG.Tweening;
using System;
using TMPro;
using UnityEngine;
using UnityEngine.UI;


public class LoadUI : UIBase
{
    

    [SerializeField] private TMP_Text _stageText;
    [SerializeField] private TMP_Text _resetCountText;

    [SerializeField] private float _startShowTime;
    [SerializeField] private float _intervalTime;
    [SerializeField] private float _hideTime;
    public override void OnOpen(Action onComplete)
    {
        this.gameObject.SetActive(true);
        SetValue(GameMgr.Instance.MapIndex,GameMgr.Instance.ResetCount);


        var sequence = DOTween.Sequence();
        sequence.Append(_stageText.DOFade(1, _startShowTime));
        sequence.Join(_resetCountText.DOFade(1,_startShowTime));
        sequence.AppendInterval(_intervalTime);
        sequence.Append(_stageText.DOFade(0, _hideTime));
        sequence.Join(_resetCountText.DOFade(0, _hideTime));
        sequence.AppendCallback(() => {
            UISystem.Instance.Show(UI_TYPE.GAME);
        });
        sequence.Play();
    }
   
    public void SetValue(int stageIndex,int resetCount) 
    {
        _stageText.text="STAGE  0"+stageIndex.ToString();
        _resetCountText.text="RESET  0"+resetCount.ToString(); 
    }

    public override void OnClose(Action onComplete)
    {
        this.gameObject.SetActive(false);
    }

    

}

